package shuati.shua;

import java.util.Scanner;
//分解质因数
public class PrimeFactorization {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入一个正整数：");
        int number = scanner.nextInt();
        
        System.out.print(number + "的质因数为：");
        primeFactors(number);
    }

    public static void primeFactors(int number) {
        // 从2开始尝试除数
        for (int i = 2; i <= number; i++) {
            // 如果i是number的因数，则输出i，并更新number
            while (number % i == 0) {
                System.out.print(i + " ");
                number /= i;
            }
        }
    }
}